import { getAppUrl } from '@/api/auth';

const helper = {
  state: {
    appAddr: '',
  },

  mutations: {
    SET_APP_ADDR(state, payload) {
      state.appAddr = payload;
    },
  },

  actions: {
    GET_APP_ADDR({ commit }, { appName }) {
      return new Promise((resolve) => {
        getAppUrl({ appName }).then((res) => {
          const { data } = res;
          commit('SET_APP_ADDR', data.visitUrl);
          resolve(data);
        });
      });
    },
  },
};

export default helper;
